package com.openroom.ui.component;

import java.net.URL;

import org.apache.pivot.beans.BXML;
import org.apache.pivot.collections.Map;
import org.apache.pivot.util.Resources;
import org.apache.pivot.wtk.media.Image;

import com.openroom.ui.MainWindow;
import com.openroom.ui.NamespaceHelper;
import com.openroom.ui.PreviewImageView;
import com.openroom.ui.UIComponent;
import com.openroom.ui.component.skin.ZoomablePreviewImageSkin;

public class ZoomablePreviewImage extends BorderImage implements UIComponent {
    @BXML
    private PreviewImageView fullImage;

    @BXML
    private FullViewImageContainer fullImageContainer;

    private float scaleX = 0.0F;
    private float scaleY = 0.0F;

    public ZoomablePreviewImage() {
        this(null);
    }

    public ZoomablePreviewImage(Image image) {
        super(image);
        installSkin(ZoomablePreviewImage.class);
    }

    @Override
    public void initialize(Map<String, Object> namespace, URL arg1,
            Resources arg2, MainWindow window) {
        NamespaceHelper.initialize(namespace, this);
        fullImageContainer.initialize(namespace, arg1, arg2, window);
    }

    public void moveTo(int x, int y) {
        fullImageContainer.setPosition(x, y);
    }

    public void setScale(int viewWidth, int viewHeight) {
        ((ZoomablePreviewImageSkin)getSkin()).setPreviewWidth(viewWidth);
        ((ZoomablePreviewImageSkin)getSkin()).setPreviewHeight(viewHeight);
    }
}
